<?php

namespace App\Admin\Extensions\Tools;

use Encore\Admin\Grid\Tools\BatchAction;

class ReleasePost extends BatchAction
{
    protected $action;

    public function __construct($action = 1)
    {
        $this->action = $action;
    }

    public function script()
    {
        $url=admin_url('crm_kehu/xiadan/');
        $url=json_encode($url);
        return <<<EOT

$('{$this->getElementClass()}').on('click', function() {
    window.location.href=$url+"/"+selectedRows();
    // $.ajax({
    //     method: 'post',
    //     url: '{$this->resource}/release',
    //     data: {
    //         _token:LA.token,
    //         ids: selectedRows(),
    //         action: {$this->action}
    //     },
        // success: function () {
        //     $.pjax.reload('#pjax-container');
        //     toastr.success('操作成功');
        // }
    // });
});

EOT;

    }
}